import matplotlib.pyplot as plt
import pandas as pd

plt.rcParams['font.sans-serif'] = ['STHeiti', 'PingFang SC', 'Heiti TC', 'Microsoft YaHei', 'SimHei', 'Arial Unicode MS']  
plt.rcParams['axes.unicode_minus'] = False

df = pd.read_csv("data-5.csv")

# 提取年份列表
years = ["2025", "2030", "2035", "2040", "2045", "2050"]

# 定义模式和对应的中文标题
modes = ["随到随充", "有序充电", "车网互动"]
mode_titles = {
    "随到随充": "UC",
    "有序充电": "V1G",
    "车网互动": "V2G"
}

def plot_comparison(scene_to_compare, base_scene_label, original_scene="基准情景", compare_scene="高碳价格"):
    fig, axes = plt.subplots(1, 3, figsize=(11, 3.5))

    for ax, mode in zip(axes, modes):
        subset = df[df["模式"] == mode]
        baseline = subset[subset["场景"] == original_scene][years].values.flatten() / 10
        compare = subset[subset["场景"] == compare_scene][years].values.flatten() / 10

        ax.scatter(years, baseline, marker='o', label=f"{base_scene_label}-{mode_titles[mode]}")
        ax.scatter(years, compare, marker='s', label=f"{scene_to_compare}-{mode_titles[mode]}")
        ax.set_xlabel("Year")
        ax.set_ylabel("Installed Capacity (MMW)")
        ax.legend()

    plt.tight_layout()
    plt.savefig("5.jpg", dpi=300)

# 第一张图：BAU-HIGH vs BAU-LOW
# plot_comparison(scene_to_compare="BAU-HIGH", base_scene_label="BAU-LOW", original_scene="基准情景", compare_scene="高碳价格")

# 第二张图：低碳排放 vs 基准碳排放
plot_comparison(scene_to_compare="SC-LOW", base_scene_label="BAU-LOW", original_scene="基准情景", compare_scene="低碳排放")